import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter/material.dart';

class warmTipDialog extends Dialog {

  Function onCloseEvent;
  Function onPositivePressEvent;
  String warmTip;
  String title;
  String agreetText;
  warmTipDialog({
    this.agreetText,
    this.title,
    this.warmTip,
    this.onPositivePressEvent,
    @required this.onCloseEvent,
  });

  //中间视图背景
  Widget CenterBG(){
    return Container(
      decoration: ShapeDecoration(
        color: Color(0xffffffff),
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.all(
            Radius.circular(15.0),
          ),
        ),
      ),
      width:ScreenUtil().setWidth(452) ,
      height: ScreenUtil().setWidth(277),
    );
  }
  //中间视图
  Widget CenterWidget(){
    return Stack(
        children: <Widget>[
          CenterBG(),
          Positioned(
            left: ScreenUtil().setWidth(0),
            top: ScreenUtil().setWidth(26),
            child: Container(
              width: ScreenUtil().setWidth(452),
              height: ScreenUtil().setWidth(25),
              child: Text(title,style: TextStyle(fontSize:ScreenUtil().setSp(18)),textAlign: TextAlign.center,),
            ),
          ),
          Positioned(
            left: 0,
            top: ScreenUtil().setWidth(72),
            child: Container(
              width: ScreenUtil().setWidth(452),
              height: ScreenUtil().setWidth(2),
              color: Color(0xffDADADA),
            ),
          ),
          Positioned(
            child: Container(
              width: ScreenUtil().setWidth(359),
              child: Text(warmTip,style: TextStyle(fontFamily: 'PingFangSC-Medium',fontSize: ScreenUtil().setWidth(18)),textAlign: TextAlign.center,maxLines: 3,overflow: TextOverflow.ellipsis,),
            ),
            top: ScreenUtil().setWidth(103),
            left: ScreenUtil().setWidth(44),
          ),
          Positioned(
            child: InkWell(
              onTap: this.onCloseEvent,
              child: Container(
                width: ScreenUtil().setWidth(159),
                height: ScreenUtil().setWidth(41),
                decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(8),
                    color:Color(0xffFFFFFF),
                    border: Border.all(
                        color: Color(0xff7086F8),
                        width: 1,
                        style: BorderStyle.solid
                    )
                ),
                child: new Text('取消',style: TextStyle(fontSize: ScreenUtil().setSp(16),color: Color(0xff586FE9 )),textAlign: TextAlign.center),
                padding: EdgeInsets.only(top: ScreenUtil().setWidth(8)),
              ),
            ),
            left: ScreenUtil().setWidth(43),
            top: ScreenUtil().setWidth(206),
          ),
          Positioned(
            child: InkWell(
                onTap:this.onPositivePressEvent,
                child: Container(
                  width: ScreenUtil().setWidth(159),
                  height: ScreenUtil().setWidth(41),
                  decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(8),
                      color:Color(0xffFFFFFF),
                      gradient: const LinearGradient(colors: [Color(0xff768CFC),Color(0xff586FE9)])
                  ),
                  child: new Text(agreetText??"确定",style: TextStyle(fontSize: ScreenUtil().setSp(16),color: Color(0xffFFFFFF)),textAlign: TextAlign.center,),
                  padding: EdgeInsets.only(top: ScreenUtil().setWidth(8)),
                )
            ),
            left: ScreenUtil().setWidth(233),
            top: ScreenUtil().setWidth(206),
          ),
        ]
    );
  }
  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(context, width: 1024, height: 640, allowFontScaling: true);
    return new Material(
      type: MaterialType.transparency,
      child: new Center(
        child: CenterWidget(),
      )
    );
  }
}